<extend name="Layout:ly1"/>

<block name="head">
    <script>
        $(document).ready(function () {
            var Table = $('table');
            var DataTable = Table.DataTable({
                language: dataTables_zh_CN,
                pageLength: 10,
                aaSorting: [
                    [0,"desc"]
                ]
            });

            //添加
            $('#add').click(function(){
                layer.open({
                    type: 2,
                    title: '添加专家',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['50%', '630px'],
                    content: '{:U("Admin/Expert/expert_add")}'
                });
            })

            //查看信息
            $('body').delegate('table tr td .view','click',function(){
                var url = $(this).parents('tr').data('view');
                layer.open({
                    type: 2,
                    title: '查看详情',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['50%', '80%'],
                    content: url
                });
            })

            //编辑信息
            $('body').delegate('table tr td .update','click',function(){
                var url = $(this).parents('tr').data('edit');
                layer.open({
                    type: 2,
                    title: '编辑用户',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['50%', '630px'],
                    content: url
                });
            })

            //上传身份证
            $('body').delegate('table tr td.acount','click',function(){
                var url = $(this).parents('tr').data('upload');
                layer.open({
                    type: 2,
                    title: '上传身份证',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['450px', '390px'],
                    content: url
                });
            })


            //删除信息
            $('body').delegate('table tr td .delete','click',function(){
                var id = $(this).parents('tr').data('id');
                var status = $(this).parents('tr').data('status');
                layer.confirm('你确定要删除吗？', {
                    btn: ['确定','取消'], //按钮
                    shade: [0.4, '#393D49'] //显示遮罩
                }, function(){
                    $.get("{:U('Admin/Expert/expert_delete')}",{"userid":id,"status":status},function(msg){
                        if(msg == 1){
                            layer.msg("删除成功，1秒后自动关闭~~",{ico:1,time:1000},function(){
                                $('table tr#id_'+id).remove();
                            })
                        }else if(msg == 2){
                            layer.msg("参数异常，1秒后自动关闭~~",{ico:1,time:1000});
                        }else{
                            layer.msg("删除失败，1秒后自动关闭~~",{ico:1,time:1000});
                        }
                    })
                }, function(){

                });
            })
        });
    </script>
</block>

<block name="body">
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">专家列表</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        专家列表
                        <a id="add" class="pull-right">添加专家</a>
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="dataTable_wrapper">
                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th align="center">ID</th>
                                        <th>姓名</th>
                                        <th>擅长作物</th>
                                        <th>擅长地区</th>
                                        <th>QQ</th>
                                        <th>职位</th>
                                        <th width="20%">个人简介</th>
                                        <th>注册时间</th>
                                        <th>状态</th>
                                        <th width="15%">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <foreach name="data" item="v" key="k" >
                                        <tr id="id_{$v.userid}" data-id="{$v.userid}" data-status="{$v.status}" data-edit="{:U('Admin/Expert/expert_edit',['userid'=>$v['userid']])}" data-view="{:U('Admin/Expert/expert_profile',['userid'=>$v['userid']])}" data-upload="{:U('Admin/Expert/expert_upload',['userid'=>$v['userid']])}">
                                            <td align="center">{$v.userid}</td>
                                            <td id="acount" class="acount" title="上传身份证照片">{$v.name}</td>
                                            <td>{$v.good_at_crop}</td>
                                            <td>{$v.good_at_area}</td>
                                            <td>{$v.qq}</td>
                                            <td>{$v.postion}</td>
                                            <td>{$v.content}</td>
                                            <td>{$v.addtime}</td>
                                            <td align="center">
                                                <if condition="$v.status eq 0">
                                                    <font color="blue">待审核</font>
                                                    <elseif condition="$v.status eq 1"/>
                                                    <font color="green">已审核</font>
                                                    <else />
                                                    <font color="red">未通过</font>
                                                </if>
                                            </td>
                                            <td align="center">
                                                <button class="btn btn-primary view">查看</button>
                                                <button class="btn btn-warning update">修改</button>
                                                <button class="btn btn-danger delete">删除</button>
                                            </td>
                                        </tr>
                                    </foreach>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
    </div>
    <!-- /#page-wrapper -->
</block>